package cos.android.voleysplash.element;

public class DinamicElement implements Cloneable {

	private float oY;
	private float oX;
	private float flexibility;
	private float weight;
	private Element lastHitted;

	public DinamicElement(float flexibility, float weight) {
		this.flexibility = flexibility;
		this.weight = weight;
		oY = 0;
		oX = 0;
		lastHitted = null;
	}

	public float getoX() {
		return oX;
	}

	public void setoX(float oX) {
		this.oX = oX;
	}

	public float getoY() {
		return oY;
	}

	public void setoY(float oY) {
		this.oY = oY;
	}

	public float getPower() {

		return (float) (Math.sqrt(Math.pow(getoX(), 2) + Math.pow(getoY(), 2)))
				* weight;
	}

	public float getSpeed() {
		return (float) (Math.sqrt(Math.pow(getoX(), 2) + Math.pow(getoY(), 2)));
	}

	public float getFlexibility() {
		return flexibility;
	}

	public void setFlexibility(float flexibility) {
		this.flexibility = flexibility;
	}

	public float getWeight() {
		return weight;
	}

	public void setWeight(float weight) {
		this.weight = weight;
	}

	public Element getLastHitted() {
		return lastHitted;
	}

	public void setLastHitted(Element lastHited) {
		this.lastHitted = lastHited;
	}

	public void applySpeed(float ox, float oy) {

		// Aplicacion de Velocidades
		oX += ox;
		oY += oy;
	}

	public void update(Element element, float elapsed) {
		

		element.setxPos(element.getxPos() + (elapsed * getoX()));
		element.setyPos(element.getyPos() + (elapsed * getoY()));
		setoX(getoX() * 0.99999f);
		setoY(getoY() * 0.99f); 
	}

	public void resetX() {
		oX = 0;
	}

	public void resetY() {
		oY = 0;
	}

	public void reset() {
		oX = 0;
		oY = 0;
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		return super.clone();
	}

}
